home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_qt.idb / usr / freeware / include / Qt / qstrlist.h.z / qstrlist.h
Encoding:
C/C++ Source or Header  |  1998-10-28  |  2.5 KB  |  94 lines

  1. /****************************************************************************
  2. ** $Id: qstrlist.h,v 2.12 1998/07/03 00:09:47 hanord Exp $
  3. **
  4. ** Definition of QStrList, QStrIList and QStrListIterator classes
  5. **
  6. ** Created : 920730
  7. **
  8. ** Copyright (C) 1992-1998 Troll Tech AS.  All rights reserved.
  9. **
  10. ** This file is part of Qt Free Edition, version 1.40.
  11. **
  12. ** See the file LICENSE included in the distribution for the usage
  13. ** and distribution terms, or http://www.troll.no/free-license.html.
  14. **
  15. ** IMPORTANT NOTE: You may NOT copy this file or any part of it into
  16. ** your own programs or libraries.
  17. **
  18. ** Please see http://www.troll.no/pricing.html for information about 
  19. ** Qt Professional Edition, which is this same library but with a
  20. ** license which allows creation of commercial/proprietary software.
  21. **
  22. *****************************************************************************/
  23.  
  24. #ifndef QSTRLIST_H
  25. #define QSTRLIST_H
  26.  
  27. #ifndef QT_H
  28. #include "qstring.h"
  29. #include "qlist.h"
  30. #include "qdatastream.h"
  31. #endif // QT_H
  32.  
  33.  
  34. #if defined(DEFAULT_TEMPLATECLASS)
  35. typedef QListT<char>            QStrListBase;
  36. typedef QListIteratorT<char>        QStrListIterator;
  37. #else
  38. typedef Q_DECLARE(QListM,char)        QStrListBase;
  39. typedef Q_DECLARE(QListIteratorM,char)    QStrListIterator;
  40. #endif
  41.  
  42.  
  43. class QStrList : public QStrListBase
  44. {
  45. public:
  46.     QStrList( bool deepCopies=TRUE ) { dc = deepCopies; }
  47.     QStrList( const QStrList & );
  48.    ~QStrList()            { clear(); }
  49.     QStrList& operator=( const QStrList & );
  50.  
  51. private:
  52.     GCI      newItem( GCI d )    { return dc ? qstrdup( (const char*)d ) : d; }
  53.     void  deleteItem( GCI d )    { if ( dc ) delete[] (char*)d; }
  54.     int      compareItems( GCI s1, GCI s2 )
  55.                 { return strcmp((const char*)s1,
  56.                         (const char*)s2); }
  57.     QDataStream &read( QDataStream &s, GCI &d )
  58.                 { s >> (char *&)d; return s; }
  59.     QDataStream &write( QDataStream &s, GCI d ) const
  60.                 { return s << (const char *)d; }
  61.     bool  dc;
  62. };
  63.  
  64.  
  65. class QStrIList : public QStrList        // case insensitive string list
  66. {
  67. public:
  68.     QStrIList( bool deepCopies=TRUE ) : QStrList( deepCopies ) {}
  69.    ~QStrIList()            { clear(); }
  70. private:
  71.     int      compareItems( GCI s1, GCI s2 )
  72.                 { return stricmp((const char*)s1,
  73.                          (const char*)s2); }
  74. };
  75.  
  76.  
  77. inline QStrList & QStrList::operator=( const QStrList &strList )
  78. {
  79.     clear();
  80.     dc = strList.dc;
  81.     QStrListBase::operator=(strList);
  82.     return *this;
  83. }
  84.  
  85. inline QStrList::QStrList( const QStrList &strList )
  86.     : QStrListBase( strList )
  87. {
  88.     dc = FALSE;
  89.     operator=(strList);
  90. }
  91.  
  92.  
  93. #endif // QSTRLIST_H
  94.